home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 322 / flex / flexdef.skl < prev    next >
Encoding:
Text File  |  1988-10-20  |  7.6 KB  |  388 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. #ifdef atarist
  4. #include "flexskdf.h"
  5. #else
  6. #include "flexskeldef.h"
  7. #endif
  8.  
  9. %% section 1 code and data tables for DFA go here
  10.  
  11. /* these declarations have to come after the section 1 code or lint gets
  12.  * confused about whether the variables are used
  13.  */
  14. #ifdef atarist
  15. FILE * yyin, * yyout;    /* init'ed in main */
  16. #else
  17. FILE *yyin = stdin, *yyout = stdout;
  18. #endif
  19.  
  20. /* these variables are all declared out here so that section 3 code can
  21.  * manipulate them
  22.  */
  23. static int yy_start, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
  24. static int yy_saw_eof, yy_init = 1;
  25.  
  26. /* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
  27.  * setting up yytext we can try to put a '\0' just past the end of the
  28.  * matched text
  29.  */
  30. static char yy_ch_buf[YY_BUF_SIZE + 1];
  31. static int yy_st_buf[YY_BUF_SIZE];
  32. static char yy_hold_char;
  33. char *yytext;
  34. static int yyleng;
  35.  
  36. YY_DECL
  37.     {
  38.     int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
  39.  
  40. %% user's declarations go here
  41.  
  42.     if ( yy_init )
  43.     {
  44.     YY_INIT;
  45.     yy_start = 1;
  46.     yy_init = 0;
  47.     }
  48.  
  49.     goto get_next_token;
  50.  
  51. do_action:
  52.     for ( ; ; )
  53.     {
  54.     YY_DO_BEFORE_ACTION
  55.  
  56. #ifdef FLEX_DEBUG
  57.     fprintf( stderr, "--accepting rule #%d\n", yy_act );
  58. #endif
  59.     switch ( yy_act )
  60.         {
  61. %% actions go here
  62.  
  63. case YY_NEW_FILE:
  64. break; /* begin reading from new file */
  65.  
  66. case YY_DO_DEFAULT:
  67. YY_DEFAULT_ACTION;
  68. break;
  69.  
  70. case YY_END_TOK:
  71. return ( YY_END_TOK );
  72.  
  73. default:
  74. YY_FATAL_ERROR( "fatal flex scanner internal error" );
  75.         }
  76.  
  77. get_next_token:
  78.     {
  79.     register int yy_curst;
  80.     register char yy_sym;
  81.  
  82.     YY_DO_BEFORE_SCAN
  83.  
  84.     /* set up to begin running DFA */
  85.  
  86.     yy_curst = yy_start;
  87.  
  88.     if ( yy_ch_buf[yy_c_buf_p] == '\n' )
  89.         ++yy_curst;
  90.  
  91.     /* yy_b_buf_p points to the position in yy_ch_buf
  92.      * of the start of the current run.
  93.      */
  94.  
  95.     yy_b_buf_p = yy_c_buf_p + 1;
  96.  
  97.     do /* until the machine jams */
  98.         {
  99.         if ( yy_c_buf_p == yy_e_buf_p )
  100.         { /* need more input */
  101.         if ( yy_e_buf_p >= YY_BUF_LIM )
  102.             { /* not enough room to do another read */
  103.             /* see if we can make some room for more chars */
  104.  
  105.             yy_n_chars = yy_e_buf_p - yy_b_buf_p;
  106.  
  107.             if ( yy_n_chars >= 0 )
  108.             /* shift down buffer to make room */
  109.             for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
  110.                 {
  111.                 yy_buf_pos = yy_b_buf_p + yy_iii;
  112.                 yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
  113.                 yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
  114.                 }
  115.  
  116.             yy_b_buf_p = 0;
  117.             yy_e_buf_p = yy_n_chars;
  118.  
  119.             if ( yy_e_buf_p >= YY_BUF_LIM )
  120.             YY_FATAL_ERROR( "flex input buffer overflowed" );
  121.  
  122.             yy_c_buf_p = yy_e_buf_p;
  123.             }
  124.  
  125.         else if ( yy_saw_eof )
  126.             {
  127. saweof:            if ( yy_b_buf_p > yy_e_buf_p )
  128.             {
  129.             if ( yywrap() )
  130.                 {
  131.                 yy_act = YY_END_TOK;
  132.                 goto do_action;
  133.                 }
  134.             
  135.             else
  136.                 {
  137.                 YY_INIT;
  138.                 yy_act = YY_NEW_FILE;
  139.                 goto do_action;
  140.                 }
  141.             }
  142.  
  143.             else /* do a jam to eat up more input */
  144.             {
  145. #ifndef FLEX_INTERACTIVE_SCANNER
  146.             /* we're going to decrement yy_c_buf_p upon doing
  147.              * the jam.  In this case, that's wrong, since
  148.              * it points to the last non-jam character.  So
  149.              * we increment it now to counter the decrement.
  150.              */
  151.             ++yy_c_buf_p;
  152. #endif
  153.             break;
  154.             }
  155.             }
  156.  
  157.         YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
  158.               YY_MAX_LINE );
  159.  
  160.         if ( yy_n_chars == YY_NULL )
  161.             {
  162.             if ( yy_saw_eof )
  163.     YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
  164.             yy_saw_eof = 1;
  165.             goto saweof;
  166.             }
  167.  
  168.         yy_e_buf_p += yy_n_chars;
  169.         }
  170.  
  171.         ++yy_c_buf_p;
  172.  
  173. #ifdef FLEX_USE_ECS
  174. #ifdef atarist
  175.         yy_sym = __e[yy_ch_buf[yy_c_buf_p]];
  176. #else
  177.         yy_sym = e[yy_ch_buf[yy_c_buf_p]];
  178. #endif
  179. #else
  180.         yy_sym = yy_ch_buf[yy_c_buf_p];
  181. #endif
  182.  
  183. #ifdef FLEX_FULL_TABLE
  184. #ifdef atarist
  185.         yy_curst = __n[yy_curst][yy_sym];
  186. #else
  187.         yy_curst = n[yy_curst][yy_sym];
  188. #endif
  189.  
  190. #else /* get next state from compressed table */
  191.  
  192. #ifdef atarist
  193.         while ( __c[__b[yy_curst] + yy_sym] != yy_curst )
  194. #else
  195.         while ( c[b[yy_curst] + yy_sym] != yy_curst )
  196. #endif
  197.         {
  198. #ifdef atarist
  199.         yy_curst = __d[yy_curst];
  200. #else
  201.         yy_curst = d[yy_curst];
  202. #endif
  203.  
  204. #ifdef FLEX_USE_MECS
  205.         /* we've arrange it so that templates are never chained
  206.          * to one another.  This means we can afford make a
  207.          * very simple test to see if we need to convert to
  208.          * yy_sym's meta-equivalence class without worrying
  209.          * about erroneously looking up the meta-equivalence
  210.          * class twice
  211.          */
  212.  
  213.         if ( yy_curst >= YY_TEMPLATE )
  214. #ifdef atarist
  215.             yy_sym = __m[yy_sym];
  216. #else
  217.             yy_sym = m[yy_sym];
  218. #endif
  219. #endif
  220.         }
  221.  
  222. #ifdef atarist
  223.         yy_curst = __n[__b[yy_curst] + yy_sym];
  224. #else
  225.         yy_curst = n[b[yy_curst] + yy_sym];
  226. #endif
  227.  
  228. #endif
  229.  
  230.         yy_st_buf[yy_c_buf_p] = yy_curst;
  231.  
  232.         }
  233. #ifdef FLEX_INTERACTIVE_SCANNER
  234. #ifdef atarist
  235.     while ( __b[yy_curst] != YY_JAM_BASE );
  236. #else
  237.     while ( b[yy_curst] != YY_JAM_BASE );
  238. #endif
  239. #else
  240.     while ( yy_curst != YY_JAM );
  241.     --yy_c_buf_p; /* put back character we jammed on */
  242.  
  243. #endif
  244.  
  245.     if ( yy_c_buf_p >= yy_b_buf_p )
  246.         { /* we matched some text */
  247.         yy_curst = yy_st_buf[yy_c_buf_p];
  248. #ifdef atarist
  249.         yy_lp = __l[yy_curst];
  250. #else
  251.         yy_lp = l[yy_curst];
  252. #endif
  253.  
  254. #ifdef FLEX_REJECT_ENABLED
  255. find_rule: /* we branch to this label when doing a REJECT */
  256. #endif
  257.  
  258.         for ( ; ; ) /* until we find what rule we matched */
  259.         {
  260. #ifdef FLEX_REJECT_ENABLED
  261. #ifdef atarist
  262.         if ( yy_lp && yy_lp < __l[yy_curst + 1] )
  263. #else
  264.         if ( yy_lp && yy_lp < l[yy_curst + 1] )
  265. #endif
  266.             {
  267. #ifdef atarist
  268.             yy_act = __a[yy_lp];
  269. #else
  270.             yy_act = a[yy_lp];
  271. #endif
  272.             goto do_action; /* "continue 2" */
  273.             }
  274. #else
  275.         if ( yy_lp )
  276.             {
  277.             yy_act = yy_lp;
  278.             goto do_action; /* "continue 2" */
  279.             }
  280. #endif
  281.  
  282.         if ( --yy_c_buf_p < yy_b_buf_p )
  283.             break;
  284.  
  285.         yy_curst = yy_st_buf[yy_c_buf_p];
  286. #ifdef atarist
  287.         yy_lp = __l[yy_curst];
  288. #else
  289.         yy_lp = l[yy_curst];
  290. #endif
  291.         }
  292.         }
  293.  
  294.     /* if we got this far, then we didn't find any accepting
  295.      * states
  296.      */
  297.  
  298.     /* so that the default applies to the first char read */
  299.     ++yy_c_buf_p;
  300.  
  301.     yy_act = YY_DO_DEFAULT;
  302.     }
  303.     }
  304.  
  305.     /*NOTREACHED*/
  306.     }
  307.  
  308.  
  309. static int unput( c )
  310. char c;
  311.  
  312.     {
  313.     YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */
  314.  
  315.     if ( yy_c_buf_p == 0 )
  316.     {
  317.     register int i;
  318.     register int yy_buf_pos = YY_BUF_MAX;
  319.  
  320.     for ( i = yy_e_buf_p; i >= yy_c_buf_p; --i )
  321.         {
  322.         yy_ch_buf[yy_buf_pos] = yy_ch_buf[i];
  323.         yy_st_buf[yy_buf_pos] = yy_st_buf[i];
  324.         --yy_buf_pos;
  325.         }
  326.  
  327.     yy_c_buf_p = YY_BUF_MAX - yy_e_buf_p;
  328.     yy_e_buf_p = YY_BUF_MAX;
  329.     }
  330.  
  331.     if ( yy_c_buf_p <= 0 )
  332.     YY_FATAL_ERROR( "flex scanner push-back overflow" );
  333.  
  334.     if ( yy_c_buf_p >= yy_b_buf_p && yy_ch_buf[yy_c_buf_p] == '\n' )
  335.     yy_ch_buf[yy_c_buf_p - 1] = '\n';
  336.  
  337.     yy_ch_buf[yy_c_buf_p--] = c;
  338.  
  339.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  340.     }
  341.  
  342.  
  343. static int input()
  344.  
  345.     {
  346.     int c;
  347.  
  348.     YY_DO_BEFORE_SCAN
  349.  
  350.     if ( yy_c_buf_p == yy_e_buf_p )
  351.     { /* need more input */
  352.     int yy_n_chars;
  353.  
  354.     /* we can throw away the entire current buffer */
  355.     if ( yy_saw_eof )
  356.         {
  357.         if ( yywrap() )
  358.         return ( EOF );
  359.  
  360.         YY_INIT;
  361.         }
  362.  
  363.     yy_b_buf_p = 0;
  364.     YY_INPUT( yy_ch_buf, yy_n_chars, YY_MAX_LINE );
  365.  
  366.     if ( yy_n_chars == YY_NULL )
  367.         {
  368.         yy_saw_eof = 1;
  369.  
  370.         if ( yywrap() )
  371.         return ( EOF );
  372.  
  373.         YY_INIT;
  374.  
  375.         return ( input() );
  376.         }
  377.  
  378.     yy_c_buf_p = -1;
  379.     yy_e_buf_p = yy_n_chars - 1;
  380.     }
  381.  
  382.     c = yy_ch_buf[++yy_c_buf_p];
  383.  
  384.     YY_DO_BEFORE_ACTION;
  385.  
  386.     return ( c );
  387.     }
  388.